package com.sunbim.rsrv.mapper;

import com.sunbim.rsrv.pojo.Relics;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author yuhui
 * @since 2021-12-30
 */
@Mapper
public interface RelicsMapper extends BaseMapper<Relics> {
    @Select("select count(1) from relics where user_id=#{userId} and relics_name=#{name}")
    boolean nameExist(Integer userId, String name);

    @Select("select count(1) from relics where id=#{id}")
    boolean idExist(int id);

    @Select("select count(1) from relics where id=#{id} and user_id=#{userId}")
    boolean relicsExist(Integer id, Integer userId);

    @Select("select count(1) from relics where user_id=#{userId}")
    int getTotal(int userId);

    List<Map<String, Object>> getAllWithDangerInfo(Integer userId);

    List<Map<String, Object>> selectGradeByUserId(Integer userId);

    List<Map<String, Object>> selectRegionByUserId(Integer userId);

    List<Map<String, Object>> selectTypeByUserId(Integer userId);

    @Select("select count(1) from relics where id<>#{id} and user_id=#{userId} and relics_name=#{relicsName}")
    boolean nameExistExcludOwn(Integer id, Integer userId, String relicsName);
}
